<?php use_helper("date");
$Invoice=$Payment->getInvoice();
?>
<div>
	<fieldset>
		<legend><?php echo __("Detalle de la Factura")?></legend>
		<div>
			<table>
				<tbody>
					<tr>
						<th><?php echo __("Usuario")?></th>
						<td><?php echo $Invoice->getUser()->getFullName()?> (<?php echo $Payment->getInvoice()->getUser()->getEmail()?>)</td>
					</tr>
					<tr>
						<th><?php echo __("Estatus")?></th>
						<td><?php echo $Invoice->getStatus()?></td>
					</tr>
					<tr>
						<th><?php echo __("Fecha de Compra")?></th>
						<td><?php echo format_date($Invoice->getCreatedAt(),"D")?></td>
					</tr>
					<tr>
						<th><?php echo __("Fecha de Caducidad")?></th>
						<td><?php echo format_date($Invoice->getExpiresAt(),"D")?></td>
					</tr>
			
					<tr>
						<td colspan="2">
							<div>
								<fieldset>
									<legend><?php echo __("Items")?></legend>
									<table>
										<thead>
											<tr>
												<th><?php echo __("Descripción")?></th>
												<th><?php echo __("Precio Unit.")?></th>
												<th><?php echo __("Cantidad")?></th>
												<th><?php echo __("Total")?></th>
											</tr>
										</thead>
										<tbody>
										
											<?php
											$totalAmount=0; 
												foreach($Invoice->getItems() as $key=>$InvoiceItem){?>
											<tr>
												<td><?php echo $InvoiceItem->getDescription() ?></td>
												<td><?php echo $InvoiceItem->getUnitPrice() ?></td>
												<td><?php echo $InvoiceItem->getQty() ?></td>
												<td><?php 
												$totalAmount+=$InvoiceItem->getUnitPrice()*$InvoiceItem->getQty();
												echo $InvoiceItem->getUnitPrice()*$InvoiceItem->getQty() ?></td>
											</tr>
											<?php }?>
										</tbody>
										<tfoot>
											<tr>
												<td colspan="3"></td>
												<td><?php  echo $totalAmount ?></td>
											</tr>
										</tfoot>
									</table>
								</fieldset>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</fieldset>
</div>
<div>
	<fieldset>
		<legend><?php echo __("Datos del Pago")?></legend>
		<div>
			<table>
				<tbody>
					<tr>
						<th><?php echo __("Tipo de Pago") ?></th>
						<td><?php echo $Payment->getPaymentType()?></td>
					</tr>
					<tr>
						<th><?php echo __("Estatus") ?></th>
						<td><?php echo $Payment->getPaymentStatus()?></td>
					</tr>
					<tr>
						<th><?php echo __("Fecha de Registro") ?></th>
						<td><?php echo format_datetime($Payment->getCreatedAt(),"f")?></td>
					</tr>
					<?php foreach($Payment->getPaymentInfos() as $key=>$PaimentInfo){?>
					<tr>
						<th><?php echo $PaimentInfo->getPaymentInfoField() ?></th>
						<td><?php echo $PaimentInfo->getValue()?></td>
					</tr>
					<?php }?>
				</tbody>
			</table>
		</div>
		<?php if(isset($formApproval) && ($formApproval instanceof sfForm)){?>
		<div>
		<br />
		<br />
		<form action="" method="post">
			<table>
				<?php echo $formApproval ?>
				<tr>
					<td colspan="2" style="text-align:center">
						<br />
						<input type="submit" class="button" value="<?php echo __("Enviar")?>"  />
					</td>
				</tr>
			</table>
		</form>
		</div>
		<?php }else{ ?>
		<div><?php echo $formApproval ?></div>
		<?php }?>
		
	</fieldset>
</div>
	